package ProjectTest;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import Utils.DateBaseUpdateUtils;

public class test extends JFrame {
	public static void main(String[] args) {

		ResultSet rs = null;
		Statement stmt = null;
		Connection conn = null;
		try {
			Class.forName("com.mysql.jdbc.Driver");

			conn = DriverManager.getConnection(
					"jdbc:mysql://123.206.212.238/Train?useUnicode=true&characterEncoding=utf8", "root", "1111");
			stmt = conn.createStatement();
			String sql = null;
			String result = null;

			rs = stmt.executeQuery("SELECT Friends FROM user WHERE name = '" + "ss" + "'");
			while (rs.next()) {
				result = rs.getString(1);
			}
			if (result != null) {
				sql = "UPDATE user SET Friends='" + result + ",cxy" + "' WHERE NAME ='" + "ss" + "'";
			} else {
				sql = "UPDATE user SET Friends='" + "cxy" + "' WHERE NAME ='" + "ss" + "'";

			}
			int n = stmt.executeUpdate(sql);

			System.out.println(n);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			try {
				rs.close();
				stmt.close();
				conn.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}

	// ArrayList<String> na = new ArrayList<>();
	// na.add("haha");
	// na.add("hehe");
	//
	// if(na.contains("haha")){
	// System.out.println("aaaaaaa");
	// }
	//
	// for (Iterator iterator = na.iterator(); iterator.hasNext();) {
	// String string = (String) iterator.next();
	// System.out.println(string);
	// }
	//
	// na.remove("haha");
	// System.out.println();
	// for (Iterator iterator = na.iterator(); iterator.hasNext();) {
	// String string = (String) iterator.next();
	// System.out.println(string);
	// }
	// Map<String, String> list = new HashMap<>();
	// list.put("aa", "b");
	// System.out.println(list.get("ada"));
	// Msg msg = new Msg();
	// msg.setFrom("aa");
	// msg.setTo("bb");
	// msg.setContent("llllllll");
	// JSONObject js = new JSONObject(msg);
	// System.out.println(js.toString());

	// JSONObject jsinfo = new JSONObject(js.toString());
	// if(jsinfo.getString("content").equals("")){
	// System.out.println(jsinfo.getString("content"));
	// }

	// int option = JOptionPane.showConfirmDialog(null,
	// "文件已修改，是否保存？", "保存文件？", JOptionPane.YES_NO_OPTION,
	// JOptionPane.WARNING_MESSAGE, null);
	// switch (option) {
	// case JOptionPane.YES_NO_OPTION: {
	// break;
	// }
	// case JOptionPane.NO_OPTION:
	// System.exit(0);
	//
	// }

}
